home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / winterp-1.13 / src-server / wc_Form.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-04  |  6.2 KB  |  165 lines

  1. /* -*-C-*-
  2. ********************************************************************************
  3. *
  4. * File:         wc_Form.c
  5. * RCS:          $Header: wc_Form.c,v 1.3 91/03/14 03:14:41 mayer Exp $
  6. * Description:  XM_FORM_WIDGET_CLASS
  7. * Author:       Niels Mayer, HPLabs
  8. * Created:      Fri Oct 27 22:35:52 1989
  9. * Modified:     Thu Oct  3 21:52:59 1991 (Niels Mayer) mayer@hplnpm
  10. * Language:     C
  11. * Package:      N/A
  12. * Status:       X11r5 contrib tape release
  13. *
  14. * WINTERP Copyright 1989, 1990, 1991 Hewlett-Packard Company (by Niels Mayer).
  15. * XLISP version 2.1, Copyright (c) 1989, by David Betz.
  16. *
  17. * Permission to use, copy, modify, distribute, and sell this software and its
  18. * documentation for any purpose is hereby granted without fee, provided that
  19. * the above copyright notice appear in all copies and that both that
  20. * copyright notice and this permission notice appear in supporting
  21. * documentation, and that the name of Hewlett-Packard and David Betz not be
  22. * used in advertising or publicity pertaining to distribution of the software
  23. * without specific, written prior permission.  Hewlett-Packard and David Betz
  24. * make no representations about the suitability of this software for any
  25. * purpose. It is provided "as is" without express or implied warranty.
  26. *
  27. * HEWLETT-PACKARD AND DAVID BETZ DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  28. * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
  29. * IN NO EVENT SHALL HEWLETT-PACKARD NOR DAVID BETZ BE LIABLE FOR ANY SPECIAL,
  30. * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  31. * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  32. * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  33. * PERFORMANCE OF THIS SOFTWARE.
  34. *
  35. * See ./winterp/COPYRIGHT for information on contacting the authors.
  36. * Please send modifications, improvements and bugfixes to mayer@hplabs.hp.com
  37. * Post XLISP-specific questions/information to the newsgroup comp.lang.lisp.x
  38. *
  39. ********************************************************************************
  40. */
  41. static char rcs_identity[] = "@(#)$Header: wc_Form.c,v 1.3 91/03/14 03:14:41 mayer Exp $";
  42.  
  43. #include <stdio.h>
  44. #include <Xm/Xm.h>
  45. #include <Xm/Form.h>
  46. #include "winterp.h"
  47. #include "user_prefs.h"
  48. #include "xlisp/xlisp.h"
  49. #include "w_funtab.h"
  50.  
  51.  
  52. extern Widget Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(); /* w_classes.c */
  53.  
  54.  
  55. /*****************************************************************************
  56.  * (send XM_FORM_WIDGET_CLASS :new 
  57.  *                           [:managed/:unmanaged]
  58.  *                           [:dialog]
  59.  *                           [<name>]
  60.  *                           <parent> 
  61.  *                           [:XMN_<arg1> <val1>]
  62.  *                           [. . .             ]
  63.  *                           [:XMN_<argN> <valN>])
  64.  *
  65.  * The optional keyword submessage :managed will cause a subsequent call
  66.  * to XtManageChild(). If the submessage :unmanaged is present, or no
  67.  * submessage, then XtManageChild() won't be called, and the resulting
  68.  * widget will be returned unmanaged.
  69.  *
  70.  *     (send XM_FORM_WIDGET_CLASS :new ...)
  71.  *     --> XmCreateForm();
  72.  *     (send XM_FORM_WIDGET_CLASS :new :dialog ...)
  73.  *     --> XmCreateFormDialog();
  74.  ****************************************************************************/
  75. LVAL Xm_Form_Widget_Class_Method_ISNEW()
  76. {
  77.   extern ArgList Wres_Get_LispArglist(); /* from w_resources.c */
  78.   extern void    Wres_Free_C_Arglist_Data(); /* from w_resources.c */
  79.   extern LVAL k_managed, k_unmanaged, k_dialog;
  80.   LVAL self, o_parent;
  81.   char* name;
  82.   Boolean managed_p, dialog_p;
  83.   Widget parent_widget_id, widget_id;
  84.  
  85.   self = xlgaobject();        /* NOTE: xlobj.c:clnew() returns an OBJECT; if this method
  86.                    returns successfully, it will return a WIDGETOBJ */
  87.  
  88.   /* get optional managed/unmanaged arg */
  89.   if (moreargs() && ((*xlargv == k_managed) || (*xlargv == k_unmanaged)))
  90.     managed_p = (nextarg() == k_managed);
  91.   else
  92.     managed_p = FALSE;        /* by default don't call XtManageChild() */
  93.  
  94.   /* get optional :dialog arg */
  95.   if (moreargs() && (*xlargv == k_dialog)) {
  96.     nextarg();
  97.     dialog_p = TRUE;
  98.   }
  99.   else
  100.     dialog_p = FALSE;        /* by default, we don't want a dialog widget */
  101.  
  102.   /* get optional <name> arg */
  103.   if (moreargs() && (stringp(*xlargv)))
  104.     name = (char*) getstring(nextarg());
  105.   else
  106.     name = "";            /* default name */
  107.  
  108.   /* get required <parent> widget-object arg */
  109.   parent_widget_id = Wcls_Get_WIDGETOBJ_Argument_Returning_Validated_WidgetID(&o_parent);
  110.  
  111.   /*
  112.    * Store the widget object <self> in the XmNuserData resource on the
  113.    * widget. This will allow us to retrieve the widget object from Xtoolkit
  114.    * functions returning widget ID's without having to keep around a table
  115.    * of widgetID-->widget-objects.
  116.    */
  117.    ARGLIST_RESET(); ARGLIST_ADD(XmNuserData, (XtArgVal) self); 
  118.  
  119.   if (moreargs()) {        /* if there are more arguments, */
  120.     Cardinal xt_numargs;    /* then we have some extra widget resources to set */
  121.     ArgList xt_arglist = Wres_Get_LispArglist(self, parent_widget_id, ARGLIST(), &xt_numargs);
  122.     if (dialog_p)
  123.       widget_id = XmCreateFormDialog(parent_widget_id, name, xt_arglist, xt_numargs);
  124.     else
  125.       widget_id = XmCreateForm(parent_widget_id, name, xt_arglist, xt_numargs);
  126.     Wres_Free_C_Arglist_Data();
  127.   }
  128.   else 
  129.     if (dialog_p)
  130.       widget_id = XmCreateFormDialog(parent_widget_id, name, ARGLIST());
  131.     else
  132.       widget_id = XmCreateForm(parent_widget_id, name, ARGLIST());
  133.  
  134.   Wcls_Initialize_WIDGETOBJ(self, widget_id);
  135.  
  136.   if (managed_p)
  137.     XtManageChild(widget_id);
  138.  
  139. #ifdef DEBUG_WINTERP_1
  140.   Wcls_Print_WidgetObj_Info(self);
  141. #endif
  142.   return (self);
  143. }
  144.  
  145.  
  146. /******************************************************************************
  147.  *
  148.  ******************************************************************************/
  149. Wc_Form_Init()
  150. {
  151.   LVAL o_XM_FORM_WIDGET_CLASS;
  152.   extern LVAL Wcls_Create_Subclass_Of_WIDGET_CLASS(); /* w_classes.c */
  153.   extern      xladdmsg();    /* from xlobj.c */
  154.  
  155.   o_XM_FORM_WIDGET_CLASS =
  156.     Wcls_Create_Subclass_Of_WIDGET_CLASS("XM_FORM_WIDGET_CLASS",
  157.                      xmFormWidgetClass);
  158.  
  159.   /* a special :isnew method on this class allows for the creation of this
  160.      widget in a popup dialog if the submessage keyword :dialog is given ... */
  161.   xladdmsg(o_XM_FORM_WIDGET_CLASS, ":ISNEW", 
  162.        FTAB_Xm_Form_Widget_Class_Method_ISNEW);
  163. }
  164.